package com.taotao.druid.visitor;

import com.alibaba.druid.sql.ast.expr.SQLIdentifierExpr;
import com.alibaba.druid.sql.ast.statement.SQLExprTableSource;
import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlASTVisitorAdapter;

/**
 * @author fanbeibei
 * @version 1.0
 * @date 2021/9/6 11:16
 */
public class MyVistor extends MySqlASTVisitorAdapter {


    private StringBuilder out;

    public MyVistor(StringBuilder out) {
        this.out = out;
    }

    @Override
    public void endVisit(SQLExprTableSource tableSource) {


        //String alias = x.getAlias();//别名
//        SQLExpr expr = x.getExpr();//表名
        //x.setExpr("mymymytable");//修改表名
        //x.setAlias("aa");//修改别名
//        System.out.println(tableSource.getExpr().toString());






        SQLIdentifierExpr table = (SQLIdentifierExpr) tableSource.getExpr();
        String tableName = table.getName();


        out.append(tableName);
    }



}
